package com.qiall.oms.service;

import com.qiall.bashutil.OsScriptUtil;
import org.springframework.stereotype.Component;
import com.qiall.uriutil.HttpUtil;

@Component
public class AppNodeService {


    private Integer managePort=10111;
    private String scripPath="tmp";

    public String shutDownService() {
        String url = buildShutDownUrl();
        String ret = HttpUtil.post(url, "");
        return ret;
    }

    public String startService() {
        String startScripPath = scripPath + "start.sh";
        String ret = OsScriptUtil.execScrip(startScripPath);
        return ret;
    }

    public String getServiceHealthInfo() {

        String url = "http://127.0.0.1:" + managePort + "/actuator/health";
       String resp= HttpUtil.get(url);
       return resp;
    }

    private String buildShutDownUrl() {
        String url = "http://127.0.0.1:" + managePort + "/actuator/shutdown";
        return url;
    }

}
